package cn.zyq.demo.system.exception;


import cn.zyq.demo.system.enums.core.ResponseCodeEnum;

public class BusinessException extends RuntimeException {

    private Integer code;

    private String msg;

    /**
     * 触发人
     */
    private final Object trigger;

    public BusinessException(ResponseCodeEnum code) {
        this(code.getCode(), code.getMsg(), null, null);
    }
    public BusinessException(String msg) {
        this(ResponseCodeEnum.ERROR.getCode(), msg, null, null);
    }
    public BusinessException(ResponseCodeEnum code, Object trigger) {
        this(code.getCode(), code.getMsg(), null, trigger);
    }

    public BusinessException(ResponseCodeEnum code, String msg) {
        this(code.getCode(), msg, null, null);
    }

    public BusinessException(ResponseCodeEnum code, String msg, Object trigger) {
        this(code.getCode(), msg, null, trigger);
    }

    public BusinessException(Integer code, String msg, Throwable cause, Object trigger) {
        super(msg, cause);

        this.code = code;
        this.msg = msg;
        this.trigger = trigger;
    }

    public BusinessException(Integer code, String msg) {
        this(code, msg, null, null);

        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return this.msg;
    }

    public Object getTrigger() {
        return trigger;
    }
}
